﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace Jimmy.Helper
{
    public class FileHelper
    {
        #region 获取项目根目录
        /// <summary>
        /// 获取项目根目录,返回值如：d:\a\b\
        /// </summary>
        /// <returns>返回值如：d:\a\b\</returns>
        public static string GetAppBasePath()
        {
            if (HttpRuntime.AppDomainAppId != null)
                return HttpRuntime.AppDomainAppPath;

            const string _PREFIX = @"file:///";
            string codeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
            codeBase = codeBase.Substring(_PREFIX.Length, codeBase.Length - _PREFIX.Length).Replace("/", "\\");
            string path = System.IO.Path.GetDirectoryName(codeBase) + @"\";
            return path;
        }
        #endregion 
    }
}
